﻿using Models;
using System;
using System.Windows;

namespace ISMv1.Controls
{
    /// <summary>
    /// Interaction logic for EditIdeaDialog.xaml
    /// </summary>
    public partial class EditIdeaDialog : Window
    {
        public Idea EditedIdea { get; set; }
        public bool WasOkClicked { get; set; }
        public bool isEditMode { get; set; }
        public bool isAddMode { get; set; }

        public EditIdeaDialog(Idea idea = null)
        {
            InitializeComponent();
            if (idea != null)
            {
                FillIdeaInformation(idea);
            }
        }

        public void SetEditMode()
        {
            this.Title = "Edit Idea";
            isEditMode = true;
            isAddMode = false;
        }

        public void SetAddMode()
        {
            this.Title = "Add New Idea";
            isEditMode = false;
            isAddMode = true;
            EditedIdea = new Idea();
        }

        private void btn_ok_Click(object sender, RoutedEventArgs e)
        {
            EditedIdea.statement = txt_content.Text;
            EditedIdea.elementNum = Int32.Parse(txt_category.Text);
            EditedIdea.clarification = txt_clarification.Text;
            EditedIdea.elementNum = Int32.Parse(txt_elemNum.Text);
            EditedIdea.elementLbl = txt_elementabel.Text;

            WasOkClicked = true;
            this.Hide();
        }

        private void FillIdeaInformation(Idea idea)
        {
            EditedIdea = idea;
            txt_category.Text = idea.category.ToString();
            txt_content.Text = idea.statement;
            txt_clarification.Text = idea.clarification;
            txt_elemNum.Text = idea.elementNum.ToString();
            txt_elementabel.Text = idea.elementLbl;

        }

        private void btn_cancel_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
        }
    }
}
